<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>通过签名公钥和挑战导出一个可用的PEM格式的公钥</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.openssl-spki-export" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_spki_export</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.6.0, PHP 7)</p><p class="refpurpose"><span class="refname">openssl_spki_export</span> &mdash; <span class="dc-title">通过签名公钥和挑战导出一个可用的PEM格式的公钥</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-spki-export-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_spki_export</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$spkac</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
    从编码的签名公钥和挑战导出PEM格式的公钥。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-spki-export-parameters">
  <h3 class="title">参数</h3>
  <dl>

    
     <dt>
<code class="parameter">spkac</code></dt>

     <dd>

      <p class="para">
        期望一个有效的签名公钥和挑战字符串。
      </p>
     </dd>

    
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-spki-export-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功，返回关联的PEM格式的公钥，失败则返回 NULL.
  </p>
 </div>


  <div class="refsect1 errors" id="refsect1-function.openssl-spki-export-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   如果传递给 <code class="parameter">spkac</code> 参数是一个不可用的参数，则会抛出一个<strong><code>E_WARNING</code></strong>级的警告。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.openssl-spki-export-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-949">
   <p><strong>Example #1 <span class="function"><strong>openssl_spki_export()</strong></span> 范例：</strong></p>
   <div class="example-contents"><p>
      成功，返回关联的PEM格式的公钥，失败则返回 NULL.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$pkey&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_pkey_new</span><span style="color: #007700">(</span><span style="color: #DD0000">'secret&nbsp;password'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$spkac&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_spki_new</span><span style="color: #007700">(</span><span style="color: #0000BB">$pkey</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'challenge&nbsp;string'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$pubKey&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_spki_export</span><span style="color: #007700">(</span><span style="color: #0000BB">preg_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'/SPKAC=/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$spkac</span><span style="color: #007700">));<br /><br />if&nbsp;(</span><span style="color: #0000BB">$pubKey</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$pubKey</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
   </div>

  </div>
  <div class="example" id="example-950">
   <p><strong>Example #2 <span class="function"><strong>openssl_spki_export()</strong></span> example from &lt;keygen&gt;</strong></p>
   <div class="example-contents"><p>
      通过&lt;keygen&gt; 元素导出关联的PEM格式的公钥：
   </p></div>
   <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$spkac&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_spki_export</span><span style="color: #007700">(</span><span style="color: #0000BB">preg_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'/SPKAC=/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'spkac'</span><span style="color: #007700">]));<br />if&nbsp;(</span><span style="color: #0000BB">$spkac&nbsp;</span><span style="color: #007700">!=&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$spkac</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Extraction&nbsp;of&nbsp;pub&nbsp;key&nbsp;failed"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;<br /></span>&lt;keygen&nbsp;name="spkac"&nbsp;challenge="challenge&nbsp;string"&nbsp;keytype="RSA"&gt;</span>
</pre></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-spki-export-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="openssl_spki_new.html" class="function" rel="rdfs-seeAlso">openssl_spki_new()</a> - 生成一个新的签名公钥和挑战</span></li>
    <li class="member"><span class="function"><a href="openssl_spki_verify.html" class="function" rel="rdfs-seeAlso">openssl_spki_verify()</a> - 验证签名公钥和挑战。</span></li>
    <li class="member"><span class="function"><a href="openssl_spki_export_challenge.html" class="function" rel="rdfs-seeAlso">openssl_spki_export_challenge()</a> - 导出与签名公钥和挑战相关的挑战字符串</span></li>
    <li class="member"><span class="function"><strong>openssl_md_method()</strong></span></li>
    <li class="member"><span class="function"><a href="openssl_csr_new.html" class="function" rel="rdfs-seeAlso">openssl_csr_new()</a> - 生成一个 CSR</span></li>
    <li class="member"><span class="function"><a href="openssl_csr_sign.html" class="function" rel="rdfs-seeAlso">openssl_csr_sign()</a> - 用另一个证书签署 CSR (或者本身) 并且生成一个证书</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>